/**
 * 系统提示
 * @constructor
 */

var toast_prefab = null;

var Toast = {

};

Toast.show = function(text, parent) {
    if (!toast_prefab) {
        cc.warn("toast_prefab is null.");
        return;
    }
    
    var toast = cc.instantiate(toast_prefab);
    if (!toast) {
        cc.war("cc.instantiate toast prefab error.");
        return;
    }
    
    toast.getComponent("toast_component").makeText = text;
    parent.addChild(toast);
};

Toast.loadPrefab = function () {
    if (!toast_prefab) {
        cc.loader.loadRes("prefab/toast_prefab", cc.Prefab, function(error, prefab) {
            if(error) {
                cc.warn("load toast_prefab error:" + error);
            } else {
                toast_prefab = prefab;
            }
        });
    }
};

module.exports = Toast;
